package com.office.service;

import com.office.bean.Emp;
import com.office.bean.EmpManger;
import com.office.bean.TDepart;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;

import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration("classpath:applicationContext.xml")
public class EmpMangertest {
    @Autowired
    EmpService empService;
    @Test
    public void finduser(){
        List<EmpManger> departAndEmp = empService.findDepartAndEmp(1, 1);
        for (EmpManger empManger : departAndEmp) {
            System.out.println(empManger);
        }
    }

    @Test
    public void allcount(){
        int i = empService.findallcoutEmp();
        System.out.println(i);
    }

    @Test
    public void findempbypage(){
        int pageIndex=1;
        int pagesize=5;

        Map<String, Object> map = new HashMap<>();
        map.put("pageIndex",pageIndex);
        map.put("pagesize",pagesize);

        int count = empService.findallcoutEmp();//总记录条数
        List<EmpManger> empMangers = empService.findempBypage(map);
        for (EmpManger empManger : empMangers) {
            System.out.println(empManger);
        }
    }

    @Test
    public void finddepart(){
        List<TDepart> finddeparts = empService.finddeparts();
        System.out.println("找到的部门为："+finddeparts);
    }
    @Test
    public void addemp(){
        SimpleDateFormat datestyle = new SimpleDateFormat("yyyy-MM-dd");
        Date date = new Date();
        String format = datestyle.format(date);

        boolean addemp = empService.addemp(new Emp(0, "mhyx", "mhyx", "mhyx", 2, 1, "男", "3432@qq.com", "343282352", "213213", format, "123123", 0));
        System.out.println(addemp);

    }
    @Test
    public void findallcount(){
        List<Integer> majorAndEmpAllcount = empService.findMajorAndEmpAllcount();
        for (Integer integer : majorAndEmpAllcount) {
            System.out.println(integer);
        }
    }
}
